#ifndef _BOOTLOADER_SHOWLOGO_H
#define _BOOTLOADER_SHOWLOGO_H

#include <sys_config.h>
#include <basic_types.h>
#include <retcode.h>
#include <hal/hal_gpio.h>
#include <hld/dis/vpo.h>
#include <hld/decv/decv.h>
#include <boot/boot_chip.h>
#include <boot/tve_hd_setting_half_mode.h>

/************For BootLogo add*******************/
extern T_VBIRequest VBIRequest;
extern struct vdec_device*  g_decv_dev ;
//struct vdec_device*  g_decv_avc_dev = NULL;
//struct vdec_device*  g_decv_dev2 = NULL;
extern struct vpo_device*   g_vpo_dev ;
extern struct vpo_device*   g_sd_vpo_dev ;

#define VDAC_USE_CVBS_TYPE      CVBS_1
#define VDAC_USE_RGB_TYPE       RGB_1
#define VDAC_USE_YUV_TYPE       YUV_1

#define CVBS_DAC                DAC3
#define RGB_DAC_R               DAC2
#define RGB_DAC_G               DAC1
#define RGB_DAC_B               DAC0

#define YUV_DAC_Y               DAC2
#define YUV_DAC_U               DAC1
#define YUV_DAC_V               DAC0

#define VOU_CTRL      (*((volatile UINT32*)(0xb8006000)))
#define VOU_CFG_HDMI  (*((volatile UINT32*)(0xb8006080)))

#define VBV_REQ_SIZE            0x80000

// the avset offset and len of struct SYSTEM_DATA must the same as system_data.h
//#define SYSTEM_DATA_LEN 1272
#define AV_SET_OFFSET (60+64)
#define AV_SET_LEN 20

typedef enum TV_SYS_TYPE
{
	TV_MODE_AUTO = 0,
	TV_MODE_PAL,
	TV_MODE_PAL_M,//  PAL3.58
	TV_MODE_PAL_N,
	TV_MODE_NTSC358,//NTSC3.58
	TV_MODE_NTSC443,
	TV_MODE_SECAM,
//#ifdef HDTV_SUPPORT
	TV_MODE_576P,
	TV_MODE_480P,
	TV_MODE_720P_50,
	TV_MODE_720P_60,
	TV_MODE_1080I_25,
	TV_MODE_1080I_30,	
	TV_MODE_BY_EDID,
	TV_MODE_1080P_50,
	TV_MODE_1080P_60,	
	TV_MODE_1080P_25,
	TV_MODE_1080P_30,	
	TV_MODE_1080P_24,
//#endif	
	TV_MODE_COUNT,
}TV_SYS_TYPE;

typedef enum
{
	TV_ASPECT_RATIO_AUTO = 0,
	TV_ASPECT_RATIO_43,
	TV_ASPECT_RATIO_169,
}TV_ASPECT_RATIO_TYPE;

typedef enum
{
    DISPLAY_MODE_NORMAL = 0,
    DISPLAY_MODE_LETTERBOX,
    DISPLAY_MODE_PANSCAN,
}DISPLAY_MODE_TYPE;

typedef enum
{
	SCART_CVBS = 0,
	SCART_RGB,
//#ifdef VDAC_USE_SVIDEO_TYPE
//	SCART_SVIDEO,
//#endif
	SCART_YUV,
}SCART_OUT_TYPE;


#ifdef BL_DISABLE_PRINTF
#define LOGO_PRINTF(...)        do{}while(0)
#else
#define LOGO_PRINTF             libc_printf
#endif

#if (defined _BOARD_DB_M3511_01V01_ || \
     defined _BOARD_DB_M3822_01V01_)

void vpo_dev_attach(void);
void vdec_dev_attach(void);
RET_CODE avInit(UINT8 tv_mode, UINT8 scart_out, UINT8 tv_ratio, UINT8 display_mode);
void avStart(enum TVSystem  tvsys, BOOL bprogressive);
void set_videologo_playback_status(INT32 playback_flag);
void set_scart_gpio(void);
INT32 bl_get_tv_set(UINT8 *p_tv_mode,UINT8 *p_scart_out,UINT8 *p_tv_ratio, UINT8 *p_display_mode);
enum TVSystem tvmode_to_tvsys(UINT8 tv_mode, UINT8 scart_out);
BOOL logo_data_is_progressive(enum TV_SYS_TYPE eTVMode);
void bl_get_show_para(enum TVSystem eTVSys, UINT16 *width, UINT16 *height);

extern RET_CODE bl_show_logo(UINT8 *buf, UINT32 len);
extern INT32 check_videologo_playback_status(void);
#endif

#endif
